#!/usr/bin/env python2

#GoodFET SPI Flash Client
#by Travis Goodspeed

import sys;
import binascii;
import array;
import time;

from GoodFETRadio import GoodFETRadio;
from intelhex import IntelHex;
from GoodFET import GoodFET, getClient;

if(len(sys.argv)==1):
    print "Usage: %s [driver|verb] verb [objects]\n" % sys.argv[0];
    print "driver:= cc51 | ccspi | nrf"; #msp430
    print "verb:=   info";
    print "         rs|radioinfo";
    print "         test";
    print "         regs";
    print "         sniff";
    print "         carrier [freq]";
    sys.exit();

driver=sys.argv[1];
print "Using driver %s" % driver;
client=GoodFETRadio(getClient(driver));
client.start();



verb=sys.argv[2];

if verb=='test':
   client.test();
if verb=='rssi':
   rssireg=client.getrssi();
   print "RSSI of %04x" % rssireg;
if(verb=="carrier"):
    if len(sys.argv)>2:
        client.RF_setfreq(eval(sys.argv[3]));
    client.RF_carrier();
    print "\nHolding a carrier wave.";
    while(1):
        time.sleep(1);


client.stop();


